#include <bits/stdc++.h>
using namespace std;
bool isPalindromic(string n)
{
	int len = n.length();
	int times = len / 2;
	for(int i = 0; i < times; i++)
		if(n[i] != n[len - i - 1])
			return false;
	return true;
}
int main()
{
	string n;
	int k;
	cin >> n >> k;
	for(int j = 0; j < k; j++)
	{
		if(isPalindromic(n))
		{
			cout << n << "\n" << j;
			return 0;
		}
		int len = n.length(), carry = 0;
		string temp;
		for(int i = 0; i < len; i++)
		{
			int sum = n[i] - '0' + n[len - i - 1] - '0' + carry;
			temp += sum % 10 + '0';
			carry = sum / 10;
		}
		if(carry != 0)
			temp += carry + '0';
		len = temp.size();
		for(int i = 0; i < len/2; i++)
		{
			char t = temp[i];
			temp[i] = temp[len - i -1];
			temp[len - i - 1] = t;
		}
		n = temp;
	}
	cout << n << "\n" << k;
	return 0;
}
